package com.example;

import javax.microedition.khronos.opengles.GL10;

import com.step.Step;
import com.step.graphic.Texture;
import com.step.scene.camera.LookAtCamera;
import com.step.sprite.Sprite3D;

public class LookAtCameraExample extends BaseExample{
	Sprite3D sprite3d;
	LookAtCamera lookAtCamera;
	
	@Override
	public void create() {
		sprite3d = new Sprite3D(new Texture("textures/wood.jpg"));
		sprite3d.setPosition(0, 0, -6);
		lookAtCamera = new LookAtCamera(67, 
				0.6f, 
				1, 1000);
		lookAtCamera.getPosition().set(0, 1, 2);
		lookAtCamera.getLookAt().set(0, 1, 1);
	}

	@Override
	public void update() {
		GL10 gl = Step.gl;
		gl.glClearColor(1, 1, 1, 1);
		// ================================================
		//Vector3D direction = lookAtCamera.getDirection();
		//lookAtCamera.getPosition().add(direction.mul(0.8f));
		lookAtCamera.updateFrustum(gl);
		// =================================================
		sprite3d.setScale(0.5f,0.5f,0.5f);
		sprite3d.rotate(2,2,2);
		sprite3d.draw(gl);
	}
}
